import prompt from '@system.prompt';
import router from '@system.router';
export default {
    data: {
        title: "",
        controlDta:""
    },
    onInit() {
        this.title = "Programme";
    },stopClick:async function(){
        this.title="自动赛";
        router.push({uri: 'pages/autoMatch/autoMatch'})
    }, startClick:async function(){
        console.log("start")
        this.controlDta="start";
        try {
            var action = this.initAction2(1002,this.controlDta);
            var result = await FeatureAbility.callAbility(action);
            console.info("onSend result = " + result);
            this.showToast("定位");
            if(this.test="Welcome to Harmony Control System"){
                this.test="";
            }
            this.test1="开始定位\n ";
        } catch (pluginError) {
            console.error("getBatteryLevel : Plugin Error = " + pluginError);
        }
        this.title="手动赛";
        router.push({uri: 'pages/index/index'})
    },initAction2: function (code,test) {
        var actionData = {};
        actionData.test = test;
        var action = {};
        action.bundleName="com.example.tcpConnect";
        action.abilityName="tcpConnectTest";
        action.messageCode = code;
        action.data = actionData;
        action.abilityType = 1;
        action.syncOption = 0;
        return action;
    },
    printData(msg){
        if(this.outcont != null || this.outcont != ""){
            this.outcont = msg + "\n" + this.outcont;
        } else {
            this.outcont = msg;
        }
    },
    showToast:function(msg){
        prompt.showToast({
            message:msg
        })
    }
}
